import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** CRM 备货单记录信息 */
export interface StockProduct {
          id: number; // 主键
          stockNo?: string; // 备货单号
          stockName?: string; // 备货单名称
          deptId: number; // 下单部门id
          projectName: string; // 项目名称
          signUserId: number; // 下单人id
          signUserName: string; // 下单人名称
          deptName: string; // 下单人部门
          finishTime?: Date; // 完成时间
          customerId: number; // 客户id
          customerName: string; //客户名称
          storeId: number; // 门店id
          storeName: string; // 门店名称
          brandName: string; // 品牌名称
          brandId: number; // 品牌id
          stockStatus?: number; // 备货单状态 0-待确认 ，1-在制中 ，2-已完成 
          stockType?: number; // 备货单类型 0-大货  
          fileUrls: string; // 备货单原始文件地址
          file: Blob; // 备货单原始文件地址
          note: string; // 备注说明
  }

// CRM 备货单记录 API
export const StockProductApi = {
  // 查询CRM 备货单记录分页
  getStockProductPage: async (params: any) => {
    return await request.get({ url: `/crm/stock-product/page`, params })
  },

  // 查询CRM 备货单记录详情
  getStockProduct: async (id: number) => {
    return await request.get({ url: `/crm/stock-product/get?id=` + id })
  },

  // 新增CRM 备货单记录
  createStockProduct: async (formData) => {
    return await request.upload({ url: `/crm/stock-product/create`, data: formData  })
  },

  // 修改CRM 备货单记录
  updateStockProduct: async (formData) => {
    return await request.upload({ url: `/crm/stock-product/update`, data: formData })
  },

  // 删除CRM 备货单记录
  deleteStockProduct: async (id: number) => {
    return await request.delete({ url: `/crm/stock-product/delete?id=` + id })
  },

  /** 批量删除CRM 备货单记录 */
  deleteStockProductList: async (ids: number[]) => {
    return await request.delete({ url: `/crm/stock-product/delete-list?ids=${ids.join(',')}` })
  },

  // 导出CRM 备货单记录 Excel
  exportStockProduct: async (params) => {
    return await request.download({ url: `/crm/stock-product/export-excel`, params })
  },
  // 下载备货单导入模板
  importStockTemplate: async () => {
    return request.download({ url: '/crm/stock-product/get-import-template' })
  }

}
// 下载产品导入模板
// export const importProductTemplate = () => {
//   return request.download({ url: '/crm/product/get-import-template' })
// }
